#include <stdio.h>
#include <string.h>

#define N_MAX 7001
#define WLEN_MAX 103


/*int
insert__after_this_series(register int index, const char *where[], int n)
{
	if (index < n) {
		++index;
		while (where[index] == where[index-1] && index < n)
			++index;
	}
	return index;
}*/



static int
insert__get_index_binsearch(const char *what, char **where, int n)
{
	int L = 0, R = n-1, M;

	while (L < R) {
		M = (L + R) / 2;
		if (strcmp(what, where[M]) >= 0)
			L = M+1;
		else
			R = M;
	}
/*	if (strcmp(where[L], what) > 0) */
		return L;
}



static void
insert(const char* what, int ind, char **array, int n)
{
	register int i;
	for (i = n; i > ind; --i) {
		array[i] = array[i-1];
	}
	array[ind] = (char*)what;
}



int
main(void)
{
	int	  n, i = 0;
	char	  array[N_MAX][WLEN_MAX];
	char	  *p_array[N_MAX];
	register int dbg_wc = 0;

	freopen("insertion.in", "rt", stdin);
	freopen("insertion.out", "w", stdout);

	(void)scanf("%d\n", &n);
	while (i < n) {
		dbg_wc += scanf("%s", &array[i][0]);
		p_array[i] = &(array[i][0]);
		if (dbg_wc < 200)
			fprintf(stderr, "\tdgb_wc == %d, word == %s\n", dbg_wc, array[i]);
		insert(p_array[i], insert__get_index_binsearch(p_array[i], p_array, i+1), p_array, i+1);
		++i;
	}

	for (i = 0 ; i < n ; ++i)
		(void)printf("%s\n", p_array[i]);
	return 0;
}
